import 'package:flutter/material.dart';
import 'package:znmm/UI/ProductPages/model/product_model.dart';
import 'package:znmm/UI/A_Common/image/cached_network_Image.dart';

class TopSwiperCell extends StatelessWidget {
  const TopSwiperCell(
    this.context, {
    Key? key,
    required this.prducMol,
    required this.index,
  }) : super(key: key);

  final ProductModel prducMol;
  final BuildContext context;
  final int index;

  @override
  Widget build(BuildContext context) {
    return prducMol.sourceUrl.isNotEmpty
        ? Padding(
            padding: const EdgeInsets.fromLTRB(2, 0, 2, 0),
            child: Stack(
              children: [
                ClipRRect(
                  borderRadius: BorderRadius.circular(10.0),
                  child: SizedBox(
                    width: double.infinity,
                    height: double.infinity,
                    child: CachedNetworkImageLoader(
                      imageUrl: prducMol.sourceUrl,
                    ),
                  ),
                ),
                Positioned(
                  top: 12.0,
                  left: 18.0,
                  child: Text(
                    prducMol.name,
                    style: const TextStyle(
                      color: Colors.white,
                      fontSize: 16.0,
                      fontWeight: FontWeight.bold,
                      shadows: [
                        Shadow(
                          color: Colors.black,
                          offset: Offset(2, 2),
                          blurRadius: 3,
                        ),
                      ],
                    ),
                  ),
                ),
              ],
            ))
        : Row(
            //测试数据
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Expanded(
                child: Padding(
                  padding: const EdgeInsets.only(left: 32),
                  child: Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        prducMol.discount,
                        style: const TextStyle(
                            fontWeight: FontWeight.bold, fontSize: 40),
                      ),
                      const SizedBox(height: 12),
                      Text(
                        prducMol.title,
                        style: const TextStyle(
                          fontWeight: FontWeight.bold,
                          fontSize: 18,
                        ),
                        overflow: TextOverflow.ellipsis,
                      ),
                      const SizedBox(height: 12),
                      Expanded(
                          child: Text(
                        prducMol.detail,
                        style: const TextStyle(
                            fontWeight: FontWeight.w500, fontSize: 12),
                      )),
                    ],
                  ),
                ),
              ),
              Image.asset(prducMol.icon),
            ],
          );
  }
}
